﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Xml;
using SEAM.Core;
using System.Diagnostics;

namespace SEAM.Data.Provider
{
    public class ConnectionProviderHandler : IConfigurationSectionHandler
    {
        internal static void Initialize()
        {
            try
            {
                ConfigurationManager.GetSection("SEAM/data/connectionProvider");
            }
            catch { }
        }

        #region IConfigurationSectionHandler Members

        public object Create(object parent, object configContext, XmlNode section)
        {
            if (section == null)
                return null;

            try
            {
                DataAccess.ConnectionProvider = (IConnectionProvider)ObjectFactory.CreateObject(section.Attributes["type"].Value);
            }
            catch (System.Exception ex2)
            {
                Trace.TraceWarning(ex2.Message + Environment.NewLine + ex2.StackTrace);
            }

            return null;

        }

        #endregion
    }
}
